// 导入二次封装axios
import koi from "@/utils/axios.ts";
// 引入接口类型
import type { ILoginParams } from "./type.ts";

// 统一管理接口
enum API {
  KOI_LOGIN = "/admin/system/login/login",
  KOI_DYNAMIC_DATA = "/admin/system/admin/getLoginUserInfo",
  KOI_USERINFO = "/user/info",
  LIST_PAGE = "/admin/system/admin/list",
  GET_BY_ID = "/admin/system/admin/read",
  UPDATE = "/admin/system/admin/update",
  ADD = "/admin/system/admin/add",
  DELETE = "/admin/system/admin/remove",
  BATCH_DELETE = "/admin/system/admin/batchDelete",
  UPDATE_STATE = "/admin/system/admin/changeStatus",
  RESET_PWD = "/admin/system/admin/resetPwd"
}
// 暴露请求函数
// 登录接口方法
export const koiLogin = (params: ILoginParams) => {
  return koi.post(API.KOI_LOGIN, params);
};

// 通过token查询相关用户信息、按钮权限、菜单权限数据，token必须有效
export const koiDynamicData = () => {
  return koi.get(API.KOI_DYNAMIC_DATA);
};

// 查询用户信息
export const koiUserInfo = (params: ILoginParams) => {
  return koi.get(API.KOI_USERINFO, params);
};

// 多条件分页查询数据
export const listPage = (params: any) => {
  return koi.get(API.LIST_PAGE, params);
};

// 根据ID进行查询
export const read = (id: any) => {
  return koi.get(API.GET_BY_ID, { id });
};

// 根据ID进行修改
export const update = (data: any) => {
  return koi.post(API.UPDATE, data);
};

// 添加
export const add = (data: any) => {
  return koi.post(API.ADD, data);
};

// 删除
export const remove = (id: any) => {
  return koi.post(API.DELETE, { id });
};

// 批量删除
export const batchDelete = (ids: any) => {
  return koi.post(API.BATCH_DELETE, ids);
};

// 修改状态
export const changeStatus = (id: any, status: any) => {
  return koi.post(API.UPDATE_STATE, { id, status }); 
};
// 重置密码
export const resetPwd = (id: any) => {
  return koi.post(API.RESET_PWD, { id }); 
};
